package com.tianlan.blog.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel(value = "Resource对象", description = "权限表")
@Entity
@Table(name = "sys_resource")
@EntityListeners(AuditingEntityListener.class)
@DynamicInsert
@DynamicUpdate
public class SysResource implements Serializable{
	
	private static final long serialVersionUID = 1L;

	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(name = "resource_name")
    private String resourceName;

    @Column(name = "parent_id")
    private Integer parentId;

    @Column(name = "resource_key")
    private String resourceKey;

    @ApiModelProperty(value = "资源类型：1、模块 2、菜单 3、按钮 4、链接")
    @Column(name = "resource_type")
    private String resourceType;

    @Column(name = "resource_icon")
    private String resourceIcon;

    @Column(name = "resource_path")
    private String resourcePath;

    @Column(name = "resource_url")
    private String resourceUrl;

    @Column(name = "resource_level")
    private Integer resourceLevel;

    @ApiModelProperty(value = "是否显示")
    @Column(name = "resource_show")
    private Boolean resourceShow;

    @ApiModelProperty(value = "是否缓存")
    @Column(name = "resource_cache")
    private Boolean resourceCache;

    @ApiModelProperty(value = "页面name")
    @Column(name = "resource_page_name")
    private String resourcePageName;

    @Column(name = "description")
    private String description;

    @Column(name = "create_time")
    private Date createTime;

    @Column(name = "creator")
    private Integer creator;

    @Column(name = "update_time")
    private Date updateTime;

    @Column(name = "operator")
    private Integer operator;

    @Column(name = "del_flag")
    private String delFlag;

    /**
     * 子菜单，必须初始化否则vue新增不展示树子菜单
     */
    @Transient
    private List<SysResource> children = new ArrayList<>();
    
    

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getResourceName() {
        return resourceName;
    }

    public void setResourceName(String resourceName) {
        this.resourceName = resourceName;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public String getResourceKey() {
        return resourceKey;
    }

    public void setResourceKey(String resourceKey) {
        this.resourceKey = resourceKey;
    }

    public String getResourceType() {
        return resourceType;
    }

    public void setResourceType(String resourceType) {
        this.resourceType = resourceType;
    }

    public String getResourceIcon() {
        return resourceIcon;
    }

    public void setResourceIcon(String resourceIcon) {
        this.resourceIcon = resourceIcon;
    }

    public String getResourcePath() {
        return resourcePath;
    }

    public void setResourcePath(String resourcePath) {
        this.resourcePath = resourcePath;
    }

    public String getResourceUrl() {
        return resourceUrl;
    }

    public void setResourceUrl(String resourceUrl) {
        this.resourceUrl = resourceUrl;
    }

    public Integer getResourceLevel() {
        return resourceLevel;
    }

    public void setResourceLevel(Integer resourceLevel) {
        this.resourceLevel = resourceLevel;
    }

    public Boolean getResourceShow() {
        return resourceShow;
    }

    public void setResourceShow(Boolean resourceShow) {
        this.resourceShow = resourceShow;
    }

    public Boolean getResourceCache() {
        return resourceCache;
    }

    public void setResourceCache(Boolean resourceCache) {
        this.resourceCache = resourceCache;
    }


    public String getResourcePageName() {
        return resourcePageName;
    }

    public void setResourcePageName(String resourcePageName) {
        this.resourcePageName = resourcePageName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Integer getCreator() {
        return creator;
    }

    public void setCreator(Integer creator) {
        this.creator = creator;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getOperator() {
        return operator;
    }

    public void setOperator(Integer operator) {
        this.operator = operator;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public List<SysResource> getChildren() {
        return children;
    }

    public void setChildren(List<SysResource> children) {
        this.children = children;
    }

    @Override
    public String toString() {
        return "Resource{" + "id=" + id + ", resourceName=" + resourceName + ", parentId=" + parentId + ", resourceKey="
                + resourceKey + ", resourceType=" + resourceType + ", resourceIcon=" + resourceIcon + ", resourcePath="
                + resourcePath + ", resourceUrl=" + resourceUrl + ", resourceLevel=" + resourceLevel + ", resourceShow="
                + resourceShow + ", resourceCache=" + resourceCache + ", resourcePageName=" + resourcePageName + ", description=" + description + ", createTime="
                + createTime + ", creator=" + creator + ", updateTime=" + updateTime + ", operator=" + operator
                + ", delFlag=" + delFlag + "}";
    }
}
